﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Demo
{
    public partial class Show1 : System.Web.UI.Page
    {
        string connectionstring1 = System.Configuration.ConfigurationManager.ConnectionStrings["DataConnectionString3"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {

            /**  try
              {
                  TextBox ty = (TextBox)Page.PreviousPage.FindControl("TextBox1");
             
              }
              catch (Exception ex)
              {
                  Response.Write("请先登陆，登陆后再进行操作!"+"（错误信息："+ex+")");
                  Response.End();
              }
          


            
              //第1步 . 建立数据连接对象
              SqlConnection con = new SqlConnection();
              con.ConnectionString = connectionstring1;
              //第二步   建立数据操作对象
              string sqlSelect = "select StudentId,Name,Password from StudentList";
              string sqlSelect1 = "select TeacherId,UserName,Password from TeacherList";
              string sqlSelect2 = "select StudentId,Grade from GradeList";
            
              con.Open();//关闭桥

              SqlCommand cmd = new SqlCommand(sqlSelect, con);
              SqlCommand cmd1 = new SqlCommand(sqlSelect1, con);
              SqlCommand cmd2 = new SqlCommand(sqlSelect2, con);


              con.Close();
              //第三步   数据适配器里显示访问
              SqlDataAdapter dap = new SqlDataAdapter();
              SqlDataAdapter dap1 = new SqlDataAdapter();
              SqlDataAdapter dap2 = new SqlDataAdapter();

              dap.SelectCommand = cmd;
              dap1.SelectCommand = cmd1;
              dap2.SelectCommand = cmd2;

              //第四步   完成数据填充
              DataTable dt = new DataTable("StudentList");
              DataTable dt1 = new DataTable("TeacherList");
              DataTable dt2 = new DataTable("GradeList");

              dap.Fill(dt);
              dap1.Fill(dt1);
              dap2.Fill(dt2);

              //第五步  将数据显示在web页面，通过数据绑定空间Gridview
              GridView1.DataSource = dt1;
              GridView1.DataBind();

              GridView2.DataSource = dt;
              GridView2.DataBind();

              GridView3.DataSource = dt2;
              GridView3.DataBind();
                   */
        }
    }
}